﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace yfxt
{
    public partial class cx_bqty_crpt : Form
    {
        public cx_bqty_crpt()
        {
            InitializeComponent();
        }

        zy_fy_DataSet ds = new zy_fy_DataSet();
        static string SQL = "data source=localhost;database=yf;uid=sa;pwd=123;timeout=60";

        private void cx_bqty_crpt_Load(object sender, EventArgs e)
        {
            string sql_bqty;
            try 
            {
                sql_bqty = "select b.zyh,b.brch,b.brxm,a.sqrq,c.ypmc,a.ypgg,a.yfdw,a.ypsl,a.ypjg,(a.ypsl*a.ypjg) as zjje,d.cdmc,e.ksmc from " +
                "bq_tymx a," +
                "zy_brry b," +
                "yk_typk c, " +
                "yk_cddz d," +
                "gy_ksdm e "+
                "where a.tjbz=2 " +
                "and a.zfpb=0 " +
                "and tybq='" + cx_bqty.ksdm + "' " +
                "and a.yfsb='" + mainform.yfsb + "' " +
                "and a.ypxh=c.ypxh " +
                "and a.zyh=b.zyh " +
                "and a.ypcd=d.ypcd " +
                "and a.tybq=e.ksdm "+
                "and a.sqrq>='" + cx_bqty.sqrq1 + "' " +
                "and a.sqrq<='" + cx_bqty.sqrq2 + "' ";

                SqlConnection con = new SqlConnection(SQL);
                SqlDataAdapter da = new SqlDataAdapter(sql_bqty, con);
                da.Fill(ds.Tables["dt_bqty"]);
                cx_brty_rpt rpt=new cx_brty_rpt();
                rpt.SetDataSource(ds);
                crystalReportViewer1.ReportSource = rpt;
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }
}
